import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.ipc.ProtocolSignature;
import org.apache.hadoop.ipc.RPC;

import java.io.IOException;

/**
 * Created by sunwangdong on 2017/3/8.
 */
public class RPCServer implements MyInterface{
    public static void main(String[] args) throws IOException
    {
        RPC.Server server = new RPC.Builder(new Configuration())
                .setBindAddress("localhost")
                .setPort(8880)
                .setInstance(new RPCServer())
                .setProtocol(MyInterface.class)
                .build();
        server.start();

    }

    public String test(String s)
    {
        System.out.println("RPCServer.test()");
        return "rpc" + s;
    }

    @Override
    public int add(int number1, int number2) {
        return number1 + number2;
    }

    @Override
    public String findName(long studentId) {
        long studentIdValue = 20210123456789L;
        if (studentIdValue == studentId) {
            return "心心";
        }
        return null;
    }


    @Override
    public long getProtocolVersion(String s, long l) throws IOException {
        return 0;
    }

    @Override
    public ProtocolSignature getProtocolSignature(String s, long l, int i) throws IOException {
        return null;
    }
}
